﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Models;

namespace Web
{
    public partial class admin_careerpage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }
        }
        private void BindData()
        {
            txbContent.Text = AboutAndCareerContentLogic.GetCareerContent();
            BindNotice();
        }

        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            string content = txbContent.Text.ToString();
            int isSuccess = AboutAndCareerContentLogic.UpdateCareerContent(content);
            if (isSuccess == 1)
            {
                ChangeStatus(true);
            }
            else
            {
                ChangeStatus(false);
            }
        }

        private void BindNotice()
        {
            noticefail.Visible = false;
            noticesuccess.Visible = false;
        }

        private void ChangeStatus(bool flag)
        {
            noticesuccess.Visible = flag ? true : false;
            noticefail.Visible = flag ? false : true;
            ScriptManager.RegisterStartupScript(this, this.GetType(), "initclosenotice", "AjaxChange();divupload();", true);
        }
    }
}
